import request from '@/utils/request'
import type {
  loginPasswordApi,
  loginPasswordReq,
  getCodeReq,
  loginPostReq,
  patientMyUserApi,
  patientMylistApi,
  patientAddReq,
  patientConsultOrderListApi,
  patientConsultOrderListReq
} from '@/types/user'

// 密码登录
export const loginPassword = (data: loginPasswordReq) => {
  return request<loginPasswordApi>('/login/password', 'post', data)
}

// 获取手机验证码
export const getCode = (data: getCodeReq) => {
  return request<{
    code: string
  }>('/code', 'get', data)
}

// 短信验证码登录
export const loginPost = (data: loginPostReq) => {
  return request<loginPasswordApi>('/login', 'post', data)
}

// 获取我的用户信息
export const patientMyUser = () => {
  return request<patientMyUserApi>('/patient/myUser')
}

// 查询患者列表
export const patientMylist = () => {
  return request<patientMylistApi[]>('/patient/mylist')
}

// 添加患者
export const patientAdd = (data: patientAddReq) => {
  return request('/patient/add', 'post', data)
}

// 删除患者
export const patientDel = (id: string) => {
  return request('/patient/del/' + id, 'DELETE')
}

// 编辑患者
export const patientUpdate = (data: patientAddReq) => {
  return request('/patient/update', 'put', data)
}

// 问诊列表
export const patientConsultOrderList = (data: patientConsultOrderListReq) => {
  return request<patientConsultOrderListApi>('/patient/consult/order/list', 'get', data)
}

// 删除问诊订单
export const patientOrder = (id: string) => {
  return request(`/patient/order/${id}`, 'DELETE')
}
// 取消问诊
export const patientOrderCancel = (id: string) => {
  return request(`/patient/order/cancel/${id}`, 'put')
}

// 三方登录
export const loginThirdparty = (data: any) => {
  return request<loginPasswordApi>('/login/thirdparty', 'post', data)
}

// 登录--绑定用户新-三方登录绑定手机号
export const loginBinding = (data: { mobile: string; code: string; openId: string }) => {
  return request<loginPasswordApi>('/login/binding', 'post', data)
}
